/*
* ============================================================================
*  Name     : VersionChecker.h
*  Part of  : GV60
*  Copyright: Wipo Software
* ============================================================================
*/

#ifndef GV60_VERSION_CHECKER_H
#define GV60_VERSION_CHECKER_H

#include <e32base.h>
#include "Version.h"
#include "HttpModule.h"


class MVersionCheckerObserver
{  
  public:
    virtual void VersionReady(TInt iResult, TGV60Version iVersion) = 0;
};

class VersionChecker: public MHttpModuleObserver
{
  public:
    VersionChecker(MVersionCheckerObserver* n_pObserver);
    virtual ~VersionChecker();

  public:
    TInt DownloadVersion();
    void CancelRequest();

  public: // static methods
    static TInt ParseVersionString(const TDesC8& n_iString, TGV60Version& n_iVersion);
    static TInt VersionToString(const TGV60Version& n_iVersion, TDes& n_iString);

  public: // From MHttpModuleObserver
    void    HttpResult(TInt iStatusCode, const TDesC8& n_iResult);

  private:
    void HttpResultVersion(TInt iStatusCode, const TDesC8& n_iResponseBody);

  private:
    TBool                    m_bBusy;
    CHttpModule*             m_pHttpModule;
    TGV60Version             m_iVersion;
    MVersionCheckerObserver* m_pObserver;
};

#endif // GV60_VERSION_CHECKER_H
